package com.xge.component_caipu.binder

import com.blankj.utilcode.util.ToastUtils
import com.xge.common_libary.bean.CaiPuListBean
import com.xge.common_libary.bean.CaiPuListSction
import com.xge.common_libary.utils.SingleDataHolder
import com.xge.common_libary.view.utils.BaseBindingBinder
import com.xge.common_libary.view.utils.BindingViewHolder
import om.xge.component_caipu.databinding.ItemAipuClassifyBinding

abstract class ItemCaiPuClassifyBinder(
    private val selectMenu:SingleDataHolder<String?>?
): BaseBindingBinder<CaiPuListBean, ItemAipuClassifyBinding>(ItemAipuClassifyBinding::inflate) {
    override fun onBindViewHolder(
        holder: BindingViewHolder<CaiPuListBean, ItemAipuClassifyBinding>,
        item: CaiPuListBean
    ) {

        holder.run {
            if(selectMenu?.query() == item.name){
                binding.tvTitle.setBackgroundColor(0xffF6FFED.toInt())
                onSelectItem(item.list)
            }else{
                binding.tvTitle.setBackgroundColor(0x00000000)
            }
            binding.tvTitle.text = item.name

            itemView.setOnClickListener {
                selectMenu?.addOrUpdate(item.name)
                adapter.notifyDataSetChanged()
            }
        }



    }

    abstract fun onSelectItem(item: List<CaiPuListSction>?)
}